package com.mac.livedatabus.core

import androidx.lifecycle.*

internal class BusLifecycleObserver<T>(
    private val mObserver: Observer<in T>,
    private val owner: LifecycleOwner,
    private val mBusLiveData: BusLiveData<T>
) : BaseBusObserverWrapper<T>(mObserver, mBusLiveData), LifecycleObserver {

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    fun onDestroy() {
        mBusLiveData.removeObserver(mObserver)
        owner.lifecycle.removeObserver(this)
    }
}